﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IsmsExplorer.Model.RiskRegister;
using IsmsExplorer.Infrastructure.Helper;
using IsmsExplorer.Infrastructure.EntityFactoryFramework;

namespace IsmsExplorer.Infrastructure.Repositories.RiskRegister {
    internal class ThreatFactory : IEntityFactory<Threat> {
        internal static class FieldNames {
            public const string ID = "ID";
            public const string ProjectID = "ProjectID";
            public const string AssetID = "AssetID";
            public const string Identification = "Identification";
            public const string Description = "Description";
            public const string Vulnerability = "Vulnerability";
            public const string Likelihood = "Likelihood";
            public const string Impact = "Impact";
        } // end internal static class FieldNames

        public Threat BuildEntity(System.Data.IDataReader reader) {
            return new Threat() {
                ID = DataHelper.GetInteger(reader[FieldNames.ID]),
                ProjectID = DataHelper.GetInteger(reader[FieldNames.ProjectID]),
                Impact = DataHelper.GetInteger(reader[FieldNames.Impact]),
                Likelihood = DataHelper.GetInteger(reader[FieldNames.Likelihood]),
                ThreatDescription = reader[FieldNames.Description].ToString(),
                ThreatIdentification = reader[FieldNames.Identification].ToString(),
                Vulnerability = DataHelper.GetInteger(reader[FieldNames.Vulnerability])
            };
        }

    }
}
